package bavaria.hightec.formatter;


import java.text.DateFormat;
import java.util.ResourceBundle;
import bavaria.hightec.banking.Account;
import bavaria.hightec.banking.Accounting;
import bavaria.hightec.banking.BankImpl;
import bavaria.hightec.exceptions.UnknownLanguageException;

public class StatementFormatterPlainTextImpl implements StatementFormatter{
	ResourceBundle statement;
	String value = null;
	private StringBuffer sb;
	DateFormat dateFormatter;
	
	public StatementFormatterPlainTextImpl() throws UnknownLanguageException{
		dateFormatter= dateFormatter.getDateInstance(2, BankImpl.getLocale().getLocale());
		statement = BankImpl.getLocale();
		sb= new StringBuffer();
	}
	
	public void addAccount(Account account){
		value=statement.getString("OWNER");
		sb.append(value + ": " + account.getAccountHolder() + "\n");
		value=statement.getString("ACCOUNTNUMBER");
		sb.append(value + ": " + account.getAccountNumber() + "\n");
		value=statement.getString("BALANCE");
		sb.append(value + ": " + account.getBalance() + "\n\n");
	}
	
	public void addTransaction(Accounting transaction){
		value=statement.getString("DATE");
		sb.append(value + ": " + dateFormatter.format(transaction.getDate())+ "\n");
		value=statement.getString("AMOUNT");
		sb.append(value + ": " + transaction.getAmount()+ "\n");
		value=statement.getString("MATTER");
		sb.append(value + ": " + transaction.getMatter()+ "\n\n");
	}
	
	public String getStatement(){
		return sb.toString();
	}
}
